define(function(require, exports, module) {
	require('jquery');
	require('easing');
	require('fancybox');

	function model(){
		this.init();
	};

	model.prototype = {

        init: function(){
            var sf = this;
            var wh = $(window).height();
            $('.user_right_wrap_box,.personal_setting_wrap_box,.social_setting_wrap_box').css({'height':wh-75});
            $('.user_right_wrap_box .tx').hover(
                function() {
                    $('.user_right_wrap_box .tx .h').css({'display':'block'});
                },
                function() {
                    $('.user_right_wrap_box .tx .h').css({'display':'none'});
                }
            );

            $('#p_setting a').on('click', function(){
                $('.btnwrap1').removeClass('bgb');
                $('#p_setting').addClass('bgb');
                $(".u_wrap_box").animate({ 
                    right: -320
                }, 10 );
                $(".personal_setting_wrap_box").animate({ 
                    right: +320
                }, 500 );
            });
            $('#s_setting a').on('click', function(){
                $('.btnwrap1').removeClass('bgb');
                $('#s_setting').addClass('bgb');
                $(".u_wrap_box").animate({ 
                    right: -320
                }, 10 );
                $(".social_setting_wrap_box").animate({ 
                    right: +320
                }, 500 );
            });

            $('.personal_setting_wrap_box .edit').on('click', function(){
                sf.changePassword();
            });

            /*改头像*/
            $('.user_right_wrap_box .tx .h').on('click',function(){
                $.fancybox.open(sf.htmltpl.filtertx,{
                    wrapCSS : 'own_skin',
                    padding : 0,
                    beforeShow: function(){
                        $('#ft1').addClass('filter-greyscale');
                    }
                });
            });

        },
        htmltpl:{
            changePassword: $('<div class="item">现有密码<br /><input type="password" class="form_text" name="" id=""></div><div class="item">新设密码<br /><input type="password" class="form_text" name="" id=""></div><div class="item">重复新设密码<br /><input type="password" class="form_text" name="" id=""></div><div class="item cf"><a href="" class="submit left">保存</a><a href="" class="cancel right">取消</a></div>'),
            changetx: $('<form id="upload_form" enctype="multipart/form-data" method="post"><input type="hidden" id="x1" name="x1" /><input type="hidden" id="y1" name="y1" /><input type="hidden" id="x2" name="x2" /><input type="hidden" id="y2" name="y2" /><div class="error"></div><div class="step2"><div class="info" style="display:none;"><label>文件大小</label> <input type="text" id="filesize" name="filesize" /><label>类型</label> <input type="text" id="filetype" name="filetype" /><label>图像尺寸</label> <input type="text" id="filedim" name="filedim" /><label>宽度</label><input type="text" id="w" name="w" /><label>高度</label><input type="text" id="h" name="h" /></div></div> <div class="changetx"><div class="inner"><div class="tx"><a href="javascript:void(0)" class="h"></a><img src="assets/images/tx.gif" alt="" id="preview" /></div><div class="selectphoto"><span class="sl-file"><input type="button" value="本地照片" class="btn-up" /><input type="file" class="sl-file-input" name="userfile" id="image_file" /></span></div><div class="uploadphoto"><input type="submit" value="上传" class="sb" /></div></div></div></form>'),
            filtertx: $('<div class="filterbox"><div class="inner"><h2 class="tit txtC">选择滤镜</h2><table class="txs"><tr><td><div class="cut"><img src="assets/images/tx.jpg" /></div><div class="tstyle">原图</div></td><td><div class="cut"><img src="assets/images/tx.jpg" id="ft1" /></div><div class="tstyle">活力</div></td></tr><tr><td><div class="cut"><img src="assets/images/tx.jpg" id="ft2" /></div><div class="tstyle">清新</div></td><td><div class="cut"><img src="assets/images/tx.jpg" id="ft3" /></div><div class="tstyle">深沉</div></td></tr></table></div></div>')
        },
        
        changePassword: function () {
            var sf = this;
            var htmlwrap = $('.personal_setting_wrap_box .items .cf').html('');
            var html = sf.htmltpl.changePassword;
            html.appendTo(htmlwrap);
        },

        
        
	};
	module.exports = new model();
});

